package com.test.demo.service.impl;

import com.test.demo.entity.Demo;
import com.test.demo.repository.DemoRepository;
import com.test.demo.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@Service
public class DemoServiceImpl implements DemoService {

    @Resource
    private DemoRepository repository;

    @Override
    public Map<String, Object> findById(Long id) {
        Map<String, Object> result = new HashMap<>(3);
        result.put("statusCode", 200);
        result.put("message", "success");
        result.put("data", repository.findById(id));
        return result;
    }

    @Override
    public Map<String, Object> save(Demo demo) {
        return repository.save(demo);
    }


}
